import request from './request'

export const updateProfile = async (profileData) => {
  return request.put('/users/me', profileData)
}

export const uploadAvatar = async (file) => {
  const formData = new FormData()
  formData.append('avatar', file)
  
  return request.post('/users/me/avatar', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

export const followUser = async (userId) => {
  return request.post(`/users/${userId}/follow`)
}

export const unfollowUser = async (userId) => {
  return request.delete(`/users/${userId}/follow`)
}

export const fetchUserById = async (userId) => {
  return request.get(`/users/${userId}`)
}

export const fetchUserFollowers = async (userId) => {
  return request.get(`/users/${userId}/followers`)
}

export const fetchUserFollowing = async (userId) => {
  return request.get(`/users/${userId}/following`)
}